package org.example;

import com.example.service.OrderService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

class Main {
    public static void main(String[] args) {
        // 加载Spring配置文件，初始化IOC容器
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        // 从容器中获取OrderService实例
        OrderService orderService = context.getBean("orderService", OrderService.class);

        System.out.println("=== 测试add方法 ===");
        orderService.add("笔记本电脑", 1);

        System.out.println("\n=== 测试delete方法 ===");
        orderService.delete("笔记本电脑");

        System.out.println("\n=== 测试find方法 ===");
        orderService.find("笔记本电脑");

        // 关闭容器
        ((ClassPathXmlApplicationContext) context).close();
    }
}
